// pages/buy/buy.js
const db = wx.cloud.database()
var app = getApp()
Page({
  data: {
    movies: [],
  },
  onLoad: function () {
    
  },
    onShow() {
      var that = this
      db.collection('movies').get().then(res => {
        var movies = []
        for (let idx in res.data) {
          var movieObj = {
            id: res.data[idx]._id,
            title: res.data[idx].title,
            poster: res.data[idx].poster
          }
          movies.push(movieObj)
        }
        that.setData({movies: movies})
      })
    },
    onMovieTap: function (event) {
      const id = event.currentTarget.dataset.id;
      console.log(id)
      wx.navigateTo({
        url: `/pages/cinema/cinema?id=${id}`
      })
    },
    onXiangqing:function(event){
      const id = event.currentTarget.dataset.id;
      console.log(id)
      wx.navigateTo({
        url: `/pages/xiangqing/xiangqing?id=${id}`
      })
    },
    toSearch:function(event){
      wx.navigateTo({
        url: `/pages/search/search?`
      })
    }
})